﻿using System;
namespace Producers.Etoimik.Xtee.Riik.Ee.Producer.Etoimik {
    
    
    [global::Xtee.Core.Attributes.XmlTypeAttribute(Name="KOLAXml", Namespace="http://producers.etoimik.xtee.riik.ee/producer/etoimik", Target=typeof(KOLAXml))]
    public class KOLAXmlSerializer : global::Xtee.Core.Types.AbstractXteeSerializable {
        
        protected IKOLAXml clazz;
        
        public KOLAXmlSerializer(IKOLAXml clazz) {
            this.clazz = clazz;
        }
        
        public override void WriteXml(global::Xtee.Core.IXteeXmlWriter Writer) {
            base.WriteXml(Writer);
            if (clazz.AsjaKood!=null) {
                Writer.WriteStartElement("AsjaKood");
                Writer.WriteTypeAttribute("http://www.w3.org/2001/XMLSchema", "int");
                Writer.WriteString(new global::Xtee.Core.Schema.XsdInt(((int)(clazz.AsjaKood))).ToString());
                Writer.WriteEndElement();
            }
            if (clazz.Xml!=null) {
                Writer.WriteStartElement("Xml");
                Writer.WriteTypeAttribute("http://www.w3.org/2001/XMLSchema", "string");
                Writer.WriteString(new global::Xtee.Core.Schema.XsdString(((string)(clazz.Xml))).ToString());
                Writer.WriteEndElement();
            }
        }
        
        public override void ReadXml(global::Xtee.Core.IXteeXmlReader Reader) {
            base.ReadXml(Reader);
            if (Reader.LocalName=="AsjaKood") {
                if ((Reader.IsElementNil() == false)) {
                    clazz.AsjaKood = new global::Xtee.Core.Schema.XsdInt(Reader.ReadElementString("AsjaKood")).Value;
                }
                else {
                    Reader.Skip();
                }
            }
            if (Reader.LocalName=="Xml") {
                if ((Reader.IsElementNil() == false)) {
                    clazz.Xml = new global::Xtee.Core.Schema.XsdString(Reader.ReadElementString("Xml")).Value;
                }
                else {
                    Reader.Skip();
                }
            }
        }
    }
}
